<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>trimStart 和 trimEnd</title>
  </head>
  <body>
    <script>
      // ES5  trim:清除字符串两侧的空白字符
      // ES10 trimStart:清除字符串左侧空白 trimEnd:清除字符串右侧空白
      let str = "   hello  world   ";
      console.log(str);
      console.log(str.trim()); // 清除字符串两侧空白
      console.log(str.trimStart()); // 清除字符串左侧空白
      console.log(str.trimEnd()); // 清除字符串右侧空白
    </script>
  </body>
</html>
